﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouxinHelper.Helper.Currency;

namespace YouxinHelper.WebSite.duowan
{
    class duowanScanner
    {
        public static string GetText(string Url) {
            String Content = "";
            string Shtml = WebHelper.HttpGet(Url);
            foreach (string Line in HtmlHelper.GetHtmlValueList(Shtml, "//div[@id='text']/p")) {
                Console.WriteLine("-------------");
                Content += HtmlHelper.GetHtmlText(Line) + "\r\n";


                string ImgSrc = HtmlHelper.GetFirstValue(HtmlHelper.GetImgSrcVlaueList(Line,"//img"));
                if (ImgSrc != "") {
                    Console.WriteLine("图片赋值");
                    Content += string.Format("![]({0})", ImgSrc);
                }
                Console.WriteLine("-------------");
            }
            return ContentClear(Content);
        }
        public static string ContentClear(string Content) {
            List<string> ExcluedeKey = new List<string>() { "&ldquo;", "&rdquo;" };
            foreach (string line in ExcluedeKey) { Content = Content.Replace(line, ""); }
            return Content;
        }

        internal static string GetTitle(string Url)
        {
            string Shtml = WebHelper.HttpGet(Url);
            return HtmlHelper.GetFirstValue(HtmlHelper.GetTextValueList(Shtml, "//article/h1"));
        }
    }
}
